<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>编辑</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
        content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all" />
    <script src="/layuiadmin/layui/layui.js"></script>
</head>

<body style="background-color:#fff">

    <div class="layui-card">
        <div class="layui-card-body">
            <form class="layui-form" action="" class="layui-form layui-form-pane" lay-filter="layui-form-pane"
                id="sbumitForm">
                <div class="layui-row layui-col-space10 layui-form-item">
                    <div class="layui-col-lg6">
                        <label class="layui-form-label">主播昵称：</label>
                        <div class="layui-input-block">
                            <input type="text" name="sort" placeholder="主播昵称" autocomplete="off" class="layui-input"
                                value="{$model.nick_name}" readonly="true" />
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">标签</label>
                    <div class="layui-input-block">
                        <select name="tag" lay-verify="required">
                            <option value="0">空</option>
                            {foreach $tags as $key=>$list }
                            <option value="{$key}" <?php if($key==$live['tag']){echo 'selected' ;}?>
                                >{$list.select_title}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>

                <div class="layui-form-item" style="margin-top: 35px">
                    <div class="layui-input-block">
                        <span class="layui-btn" onclick="submitForm()" style="width: 100%">确认修改</span>
                    </div>
                </div>
            </form>
        </div>
    </div>

    <script>
        layui.use(['form'], function () {
            $ = layui.jquery;
            var form = layui.form, layer = layui.layer;
        });

        function submitForm() {
            layer.confirm('确认要修改标签吗？', { icon: 6 }, function () {
                $.ajax({
                    type: "POST", //请求方式
                    url: '/admin/live/tag?id={$model.id}', //请求地址
                    dataType: "json", //返回的数据类型
                    data: $("#sbumitForm").serialize(), //数据
                    //请求成功
                    success: function (data) {
                        if (data.code == 0) {
                            layer.msg(data.msg, { icon: 1, time: 2000 }, function () {
                                var index = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(index);
                                window.parent.location.reload();
                            });
                        } else {
                            layer.msg(data.msg, { icon: 2, time: 5000 }, function () {
                                var index = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(index);
                            });
                        }
                    },
                    //请求失败
                    error: function (e) {
                    }
                });
            });
        }

    </script>
</body>

</html>